#include "DKInclude.h"

DKConfiguration::DKConfiguration()
{
	
}

DKConfiguration::~DKConfiguration()
{
}

// Row: sender
// Col: receiver
int senderActionTypeLogicTable[6][6] = 
{
//   G, S, M, B, L, l
	{0, 0, 0, 0, 0, 0}, // DKActorType_Grass
	{1, 0, 0, 0, 0, 0}, // DKActorType_Stone
	{1, 0, 0, 2, 0, 0}, // DKActorType_TheMan
	{1, 0, 0, 0, 0, 0}, // DKActorType_Box
	{1, 0, 0, 0, 0, 0}, // DKActorType_Lazer_Machine
	{1, 0, 0, 0, 0, 2}  // DKActorType_Lazer
};
int receiverActionTypeLogicTable[6][6] = 
{
//   G, S, M, B, L, l
	{0, 0, 0, 0, 0, 0}, // DKActorType_Grass
	{0, 0, 0, 0, 0, 0}, // DKActorType_Stone
	{0, 0, 0, 2, 0, 0}, // DKActorType_TheMan
	{0, 0, 0, 0, 0, 0}, // DKActorType_Box
	{0, 0, 0, 0, 0, 0}, // DKActorType_Lazer_Machine
	{0, 0, 0, 0, 0, 2}  // DKActorType_Lazer
};

DKActionType DKConfiguration::getSenderActionType(DKActorType sender, DKActorType receiver)
{
	return static_cast<DKActionType>(senderActionTypeLogicTable[(int)sender][(int)receiver]);
}

DKActionType DKConfiguration::getReceiverActionType(DKActorType sender, DKActorType receiver)
{
	return static_cast<DKActionType>(receiverActionTypeLogicTable[(int)sender][(int)receiver]);
}

//DKActionType DKConfiguration::getSenderActionType(DKActorType sender, DKActorType receiver)
//{
//	if(sender == DKActorType_TheMan && receiver == DKActorType_Box) return DKActionType_MoveTo;
//	else if(sender == DKActorType_Lazer && receiver == DKActorType_Lazer) return DKActionType_MoveTo;
//	if(receiver == DKActorType_Grass) return DKActionType_SlipOn;
//	return DKActionType_None;
//}
//
//DKActionType DKConfiguration::getReceiverActionType(DKActorType sender, DKActorType receiver)
//{
//	if(sender == DKActorType_TheMan && receiver == DKActorType_Box) return DKActionType_MoveTo;
//	else if(sender == DKActorType_Lazer && receiver == DKActorType_Lazer) return DKActionType_MoveTo;
//	return DKActionType_None;
//}

DKAction * DKConfiguration::getSenderAction(DKEventDirection direction, DKActor *sender, DKActor *receiver)
{
	DKActionType actionType = DKActionType_None;
	if(sender != NULL &&  receiver != NULL) actionType = getSenderActionType(sender->actorType, receiver->actorType);
	DKAction *result = new DKAction(sender, actionType);
	result->direction = direction;
	return result;
}

DKAction * DKConfiguration::getReceiverAction(DKEventDirection direction, DKActor *sender, DKActor *receiver)
{
	DKActionType actionType = DKActionType_None;
	if(sender != NULL &&  receiver != NULL) 
	{
		actionType = getReceiverActionType(sender->actorType, receiver->actorType);
	}
	DKAction *result = new DKAction(sender, actionType);
	result->direction = direction;
	return result;
}
